<?php 

function p($msg){
	echo "<Pre>".print_r($msg,true).'</pre>';
}
function upload(){
	$data=array();
	foreach ($_FILES as $name=>$file) {
		if ($file['error']>0||!is_uploaded_file($file['tmp_name']))continue;
	$info=pathinfo($_FILES[$name]['name']);
	$path='Upload/'.date('y/m/d');
	is_dir($path)or mkdir($path,0755,true);
	$toFile=$path.'/'.mt_rand(1,1000).time().'.'.$info['extension'];
	if(move_uploaded_file($_FILES[$name]['tmp_name'], $toFile)){
			$file['time']=time();
			$file['ext']=$info['extension'];
			$file['file']=$toFile;
			$data[]=$file;
		}
	}
	return $data;
}
function addImage($file){
	global $imageDb;
	$imageDb = array_merge($imageDb,$file);
	return file_put_contents('data/image.php',
	 '<?php return '.var_export($imageDb,true).';?>');
}
function success($msg){
	require 'view/success.html';
} 
function error($msg){};
 ?>